package com.itc.bi.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.Date;

@TableName("tb_datasource")
@ApiModel(value = "数据库连接信息",description = "数据库连接信息")
@Data
public class DatasourceEntity {
    @TableId(value = "id",type = IdType.ASSIGN_ID)
    @ApiModelProperty("主键")
    private Long id;

    @TableField(value = "type")
    @ApiModelProperty(value = "类型   MYSQL  ORACLE  GAUSSDB",required = true)
    @NotBlank(message = "类型不能为空")
    private String type;

    @TableField(value = "name")
    @ApiModelProperty(value = "连接名称",required = true)
    @NotBlank(message = "连接名称不能为空")
    private String name;

    @TableField(value = "driver")
    @ApiModelProperty(value = "驱动",required = true)
    @NotBlank(message = "驱动不能为空")
    private String driver;

    @TableField(value = "user_name")
    @ApiModelProperty(value = "用户名",required = true)
    @NotBlank(message = "用户名不能为空")
    private String userName;

    @TableField(value = "password")
    @ApiModelProperty(value = "密码",required = true)
    @NotBlank(message = "密码不能为空")
    private String password;

    @TableField(value = "jdbc_url")
    @ApiModelProperty(value = "JDBC连接信息",required = true)
    @NotBlank(message = "JDBC连接信息不能为空")
    private String jdbcUrl;

    @TableField(value = "encode")
    @ApiModelProperty("编码")
    private String encode;

    @TableField(value = "schema_name")
    @ApiModelProperty("模式")
    private String schemaName;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "version")
    @ApiModelProperty(value = "版本",hidden = true)
    private String version;

    @TableField(value = "remark")
    @ApiModelProperty(value = "备注",hidden = true)
    private String remark;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @ApiModelProperty(value = "创建时间",hidden = true)
    private Date createTime;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "create_by",fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建人",hidden = true)
    private String createBy;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    @ApiModelProperty(value = "修改时间",hidden = true)
    private Date updateTime;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "update_by",fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "修改人",hidden = true)
    private String updateBy;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(value = "is_deleted")
    @ApiModelProperty(value = "删除状态",hidden = true)
    @TableLogic
    private boolean isDeleted;

}
